﻿using MediatR;
using System.WXT.Domain;
using System.WXT.Infrstructre.Interface;
using System.WXT.WebAPI.Application.Command.WorkerHourCommand;

namespace System.WXT.WebAPI.Application.CommandHandlers.WorkeHourCommandHandlers
{
    public class WorkeHourUpdateCommandHandlers:IRequestHandler<WorkerHourUpdateCommand,int>
    {
        protected readonly IWorkerHourRepository workerHourRepository;

        public WorkeHourUpdateCommandHandlers(IWorkerHourRepository workerHourRepository)
        {
            this.workerHourRepository = workerHourRepository;
        }
        /// <summary>
        /// 工人工时修改
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<int> Handle(WorkerHourUpdateCommand request, CancellationToken cancellationToken)
        {
            var list = await workerHourRepository.Update(new Domain.WorkerHour { workerHourId = request.workerHourId, workerHourNumbering = request.workerHourNumbering, workerHourName = request.workerHourName, workerHourPhone = request.workerHourPhone, workerHourDuration = request.workerHourDuration, workerHourDepartment = request.workerHourDepartment, workerHourRest = request.workerHourRest });
            return list;
        }
    }
}
